/*  Copyright (C) 2008  Alexander Blyzniuchenko (BlezAlex)

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

using System.IO;
using Aga.Controls.Tree;
using DC;

namespace MediaDC
{
    class FileNode : Node
    {
        private readonly DcFile _file;
        private readonly string _extension;
        private readonly string _filePath;
        private readonly string _nickName;
        private readonly int _hubConnectionID;

        private int _users;

        public FileNode(FoundFileEventArgs args)
        {
            _file = args.File;
            _extension = Path.GetExtension(args.File.Name);
            _filePath = args.Path;
            _nickName = args.Nick;
            Image = Native.NativeImageList.GetFileIcon(Extension);
            _hubConnectionID = args.HubConnectionID;
            _users = 1;
        }

        public string FileName
        {
            get { return _file.Name; }
        }

        public string Extension
        {
            get { return _extension; }
        }

        public string FilePath
        {
            get { return _filePath; }
        }

        public string NickName
        {
            get { return _nickName; }
        }

        public long Size
        {
            get { return _file.Size; }
        }

        public string TTH
        {
            get { return _file.TTH; }
        }

        public int Users
        {
            get { return _users;  }
            set { _users = value; }
        }

        public DcFile File
        {
            get { return _file; }
        }

        public string UsersForDisplay
        {
            get { return Nodes.Count == 0 ? string.Empty : _users.ToString(); }
        }
        
        public int HubConnectionID
        {
            get { return _hubConnectionID; }
        }
    }
}
